1. Field of the Invention
The present invention is related to a data transfer method, and more particularly, to a data transfer method that is able to save memory used for storing packets in the Universal Serial Bus (USB) protocol.
2. Description of the Prior Art
Please refer to FIG. 1. FIG. 1 is a diagram illustrating the packet format of a packet DP of USB 3.0 standard. As shown in FIG. 1, the packet DP comprises a header H and a payload P. The header H comprises a type information TP, an end point information EP, a link command word LW, a header error checking code CRCH, and a reserved section RA. The payload P comprises a data sector D and a data error checking code CRCD.
The type information TP can be utilized to determine the packet type of the packet DP; packet type, for instances, specifies the packet is of handshake or data etc. Endpoint information EP can be utilized to determine the transfer type of the packet DP; for instances, USB 3.0 standard specifies four transfer types: the control transfer type, the interrupt transfer type, the bulk transfer type and the isochronous transfer type. Each transfer type is utilized to transfer data of different characteristics; the isochronous transfer type, for example, carries out real-time data transfer which is preferred for applications such as voice and video communication, so issues of lagging or delaying can be avoided. The link command word LW is utilized to identify the condition of the data linkage. The link command word further comprises a link command word error checking code CRCL and a header sequence number HSEQ. The link command word error checking code CRCL is utilized to determine whether the link command word LW is correct or not. The header sequence number HSEQ is utilized to determine if the packet sequence of which the packet DP is sent/received is correct. The header error checking code CRCH is utilized to determine whether the header H contains any error. The reserved section RA is utilized to store data defined by the user.
The data sector D provides the actual data transmitted from the transmitter, such as the video data captured from the camera or the data stored in a flash drive. The data error checking code CRCD is utilized to determine whether the data sector D contains any error. In addition, the data sector D comprises N data SD1˜SDN.
Conventionally, the data transfer via USB protocol involves the transmitter T and the receiver R. The transmitter T can be a host or a device, and the receiver R is a host or device corresponding to the transmitter T. When transferring packets, the transmitter T and the receiver R process data according to sequences from the bottom physical layer PH, the data link layer DL and the upper protocol layer PR. The operations of the receiver R receiving the packet DP and the transmitter T transmitting the packet DP are specified below.
When the receiver R receives the packet DP, the receiver R stores the packet DP in the data link memory DLM of the data link layer DL of the receiver R. When the data link layer DL of the receiver R has determined the header H of the packet DP is correct, the data link layer DL of the receiver R duplicates the packet DP stored in the data link memory DLM to the protocol memory PRM of the protocol layer PR of the receiver R. This way, the protocol layer PR of the receiver R can access packet DP stored in the protocol memory PRM for later uses.
When the transmitter T is transmitting the payload P, the protocol layer PR of the transmitter T generates the header H according to the payload P, as well as generating the packet DP in the protocol memory PRM of the protocol layer PR of the transmitter T according to the header H and the payload P. The transmitter T then duplicates the packet DP stored in the protocol memory PRM to the data link memory DLM of the data link layer DL of the transmitter T. This way, the protocol layer PRM of the transmission T can notify the data link layer DL of the transmitter T to transmit the packet DP stored in the data link memory DLM.
It is obvious that the protocol layer PR and the data link layer DL of both of the transmitter T and the receiver R require memory (i.e. the protocol memory PRM plus the data link memory DLM) to store packets. In other words, when receiving or transmitting the packet DP, one packet DP would occupy the memory space that is twice the size of the packet DP in the receiver R or the transmitter T, respectively. Consequently, the excess usage of memory increases the cost, causing inconvenience to the user.